import { _decorator, Component, Node, Label } from 'cc';
import { ComponentBase } from '../message/ComponentBase';
import { Message, MessageCmd } from '../message/Message';
import { ManagerUI } from './ManagerUI';
const { ccclass, property } = _decorator;

@ccclass('Score')
export class Score extends ComponentBase {
    start() {
        ManagerUI.instance.onRegister(this);
    }

    onReceiveMessage (message:Message){
        
        console.log(message);
        
        if(message.cmd==MessageCmd.CmdHP){
            this.changeLabel(<number>message.content)
        }
    }

    changeLabel(score:number){
        this.node.getComponent(Label).string = '得分' + score;
    }
}

